import {NgModule} from '@angular/core';
import {Routes, RouterModule, PreloadAllModules} from '@angular/router';
import {SsCommonModule} from "./common/common.module";
import {HomeComponent} from "./home/home.component";
import {IndexComponent as TableIndexComponent} from "./tables/index.component";
import {ListComponent as TableListComponent} from "./tables/list/list.component";
import {PublishComponent as TablePublishComponent} from './tables/publish/publish.component';
import {FieldComponent as TableFieldComponent} from './tables/publish/field/field.component';
import {FormComponent as TableFormComponent} from './tables/publish/form/form.component';
import {ListComponent as ProceduresListComponent} from "./procedures/list/list.component";
import {AuditComponent as ProceduresCreateAuditComponent} from './procedures/publish/audit/audit.component';
import {NormalComponent as ProceduresCreateNormalComponent} from './procedures/publish/normal/normal.component';


const routes: Routes = [
  {path: '', component: HomeComponent, pathMatch: 'full'},
  {path: 'home', component: HomeComponent, pathMatch: 'full'},
  // tables
  {path: 'spaces/:spaceId/tables', component: TableIndexComponent},
  {path: 'spaces/:spaceId/tables/create/:action', component: TablePublishComponent},
  {path: 'tables/:tableId', component: TableListComponent},
  // procedures
  {path: 'spaces/:spaceId/procedures', component: ProceduresListComponent},
  {path: 'spaces/:spaceId/procedures/create/audit', component: ProceduresCreateAuditComponent},
  {path: 'spaces/:spaceId/procedures/create/normal', component: ProceduresCreateNormalComponent}
];

@NgModule({
  declarations: [
    HomeComponent,
    // tables
    TableIndexComponent, TableListComponent,
    TableFieldComponent, TableFormComponent,
    // procedures
    ProceduresListComponent, ProceduresCreateAuditComponent, ProceduresCreateNormalComponent, TablePublishComponent,
  ],
  imports: [
    SsCommonModule, RouterModule.forRoot(routes, {useHash: false, preloadingStrategy: PreloadAllModules})
  ],
  exports: [RouterModule]
})
export class MainModule {
}
